<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8">
    <title>MIS</title>
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">


    <link rel="stylesheet" type="text/css" href="../../lib/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../../stylesheets/theme.css">
    <link rel="stylesheet" href="../../lib/font-awesome/css/font-awesome.css">


    <script src="../../lib/jquery.min.js" type="text/javascript"></script>
    <script src="../../lib/bootstrap/js/bootstrap.js"></script>
    <script src="../../lib/jquery.validate.min.js"></script>
    <script src="../../lib/jquery.cookie.js"></script>
    <script src="../../js/init.js"></script>

    <!-- Demo page code -->

    


    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="lib/html5.js"></script>
    <![endif]-->

    <!-- Le fav and touch icons -->

  </head>

  <!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]-->
  <!--[if IE 7 ]> <body class="ie ie7 "> <![endif]-->
  <!--[if IE 8 ]> <body class="ie ie8 "> <![endif]-->
  <!--[if IE 9 ]> <body class="ie ie9 "> <![endif]-->
  <!--[if (gt IE 9)|!(IE)]><!--> 
  <body class=""> 
  <!--<![endif]-->
    
    <div class="navbar">

    </div>
    
    

    
   <div class="row-fluid">
    <div class="dialog">

        <div class="block">
        
            <p class="block-heading">登录</p>
            <div class="block-body error">
                <form id="loginform" method="get" action="" >
                
                    <label for="userName">用户名</label>
                    <input type="text" class="span12" required id="userName" name="userName">
                    
                    <label for="pwd">密码</label>
                    <input type="password" id="pwd" required class="span12 " name="pwd">
                    
                    <label id="login-error" style="display:none;" class="alert-danger span8">用户名或密码错误</label>
                    <input id="btn_login" type="button" data-loading-text="登录中..." class="btn btn-primary pull-right" value="登录">
                    <div class="clearfix"></div>
                </form>
            </div>
        </div>

    </div>
</div>



    <script type="text/javascript">
    //监听回车 触发登录
    document.onkeydown=login;  
    function login(e) {    
        // 兼容FF和IE和Opera    
        var theEvent = e || window.event;    
        var code = theEvent.keyCode || theEvent.which || theEvent.charCode;    
        if (code == 13) {    
        	$("#btn_login").click();
        }    
    }  
    	

        $("#btn_login").on("click",function(){
        	
        	$("#login-error").hide();
        	
            if($("#loginform").valid()){
  	        	var userName = $("#userName").val();
            	var pwd = $("#pwd").val();
    			

            	$("#btn_login").button('loading');
            	
            	var url = api_login_url+"server/login.json?userName="+userName+"&pwd=" + pwd;
            	$.ajax({
            		url:url,
            		data:pwd,
            		contentType: "application/json",
            		type:"post",
            		dataType : "json",
            		success: function(data){
            			if(data.code == "200"){
             				window.location.href="../system/homepage.html";
            			}else{
            				 $("#login-error").text(data.msg);
            				 $("#login-error").show();
            			}
            			
            			$("#btn_login").button('reset');
            		},
            		error:function(data){
            			 $("#login-error").text('网络错误');
        				 $("#login-error").show();
        				 $("#btn_login").button('reset');
            		}
            	});
            	
            }
        });
    </script>
    
  </body>
</html>


